<template>
  <div class="detail">
    <div class="img">
      <img :src="filmdetail.poster" alt="" />
    </div>
    <div>
      <div>
        {{ filmdetail.name }}
      </div>
      <div>
        {{ filmdetail.category }}
      </div>
      <div>上映时间 {{ filmdetail.premiereAt | timeright }}</div>
      <div>
        {{ filmdetail.nation }}
      </div>
      <div>
        {{ filmdetail.synopsis }}
      </div>
    </div>

    <!-- swiper照片的渲染  -->
    <div class="swiper">
      <swiper :key="'acotor'+actors.length"> 
          <div 
            v-for="(item,index) in actors"
            :key="index"
            class="swiper-slide"
          >
                <div>
                    <img v-lazy="item.avatarAddress" alt="">
                </div>
          </div>
      </swiper>
    </div>

    <div class="ticket">购票</div>

    <!-- 返回按钮 -->
    <div @click="back" class="back">
        <i class="iconfont icon-fanhui1"></i>
    </div>
  </div>
</template>

<script>
import swiper from "@/components/swiper";
import moment from "moment";
import { moviedetaillistdata } from "@/api/api";

// export const moviedetaillistdata = (filmid)=>{
//     // api 可以改变请求头的参数 用来改变host
//     http.defaults.headers.info='info'
//     return http.get(moiveDetailUrl+filmid)
// }

export default {
  props: [],
  components: { swiper },
  data() {
    return {
      filmdetail: "",
      actors:''
    };
  },

  methods: {
      back(){
          this.$router.go(-1)
      }
  },

  computed: {},

  watch: {},

  filters: {
    timeright: function (value) {
      console.log("来到timeright过滤器");

      return moment(value * 1000).format("YYYY-MM-DD");
    },
  },

  beforeCreate() {},

  created() {
    //    eventbus  全局挂载的这个事件总线  向外部发射一个信息 信息叫做footnav 信息的数据是布尔 false

    setTimeout(() => {
      this.eventbus.$emit("footnav", false);
    }, 0);

    console.log("detail created");
    console.log(this.$route);

    moviedetaillistdata(this.$route.params.filmid).then((res) => {
      console.log(res);
      this.filmdetail = res.data.data.film;
      this.actors = this.filmdetail.actors
    });
  },

  beforeMount() {},

  mounted() {
    console.log("detail mounted生命周期");
    //   moment.locale('zh-cn');
    //  var time1 = moment().format('MMMM Do YYYY, h:mm:ss a');
    //  console.log('time1',time1)
  },

  beforeUpdate() {},

  updated() {},

  beforeDestroy() {},

  destroyed() {
    //    eventbus  全局挂载的这个事件总线  向外部发射一个信息 信息通道叫做footnav 信息的数据是布尔 true

    setTimeout(() => {
      this.eventbus.$emit("footnav", true);
    }, 0);
  },
};
</script>


<style  lang='scss'>
@import "../../assets/scss/color.scss";
.detail {
  .swiper-slide {
    img {
      width: 80px;
    }
  }
  .img {
    width: 100%;
    height: 260px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

.ticket {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 60px;
  background-color: orangered;
  color: whitesmoke;
  line-height: 60px;
  text-align: center;
  font-size: 20px;
}

.back {
  position: fixed;
  top: 0;
  left: 0;
}
.icon-fanhui1 {
  color: orangered;
}

.ticket {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 60px;
  background-color: $colorA;
  color: $colorK;
  line-height: 60px;
  text-align: center;
  font-size: 20px;
}



.back {
    position: fixed;
    top: 0;
    left: 0;
}

.icon-fanhui1 {
    color: orangered;
}
</style>
